Repository navigation
feat(memory): support event tag filtering - #3850
Merged
Merged
Conversation
Add session-level default event tags, commit-time overrides, durable queue propagation, and first-write vector index tagging. Include config update APIs and coverage for serialization, concurrency, extraction, and HTTP behavior. Co-authored-by: TRAE CLI <noreply@bytedance.com>
Add session default tag configuration, config updates, and commit-time event tag overrides across embedded Python, standalone Python, TypeScript, Go, and the Rust CLI. Preserve explicit empty-tag semantics and document each public interface. Co-authored-by: TRAE CLI <noreply@bytedance.com>
Forward commit-time event tags through the legacy Python HTTP shims and align BaseClient session signatures without adding a new abstract-method requirement for existing subclasses. Co-authored-by: TRAE CLI <noreply@bytedance.com>
Extend PATCH session config to atomically update event tags and auto-commit settings. Merge policy objects by field, use explicit null to disable automatic commits, preserve omitted fields, and expose the contract across SDKs and CLI. Co-authored-by: TRAE CLI <noreply@bytedance.com>
Replace the generic session create config JSON flag with explicit event-tag and auto-commit options. Preserve omitted, object, and null auto-commit semantics across HTTP, embedded clients, SDKs, and CLI, reject ambiguous null policy fields, and handle nullable event configuration consistently. Co-authored-by: TRAE CLI <noreply@bytedance.com>
qin-ctx
approved these changes
Aug 10, 2026
15 of 21 tasks
skloxo
pushed a commit
to skloxo/OpenVikingStudio
that referenced
this pull request
Aug 22, 2026
* feat(memory): support event tag filtering Add session-level default event tags, commit-time overrides, durable queue propagation, and first-write vector index tagging. Include config update APIs and coverage for serialization, concurrency, extraction, and HTTP behavior. Co-authored-by: TRAE CLI <noreply@bytedance.com> * feat(memory): expose event tags in SDKs and CLI Add session default tag configuration, config updates, and commit-time event tag overrides across embedded Python, standalone Python, TypeScript, Go, and the Rust CLI. Preserve explicit empty-tag semantics and document each public interface. Co-authored-by: TRAE CLI <noreply@bytedance.com> * fix(sdk): align legacy session tag APIs Forward commit-time event tags through the legacy Python HTTP shims and align BaseClient session signatures without adding a new abstract-method requirement for existing subclasses. Co-authored-by: TRAE CLI <noreply@bytedance.com> * feat(session): allow updating auto-commit policy Extend PATCH session config to atomically update event tags and auto-commit settings. Merge policy objects by field, use explicit null to disable automatic commits, preserve omitted fields, and expose the contract across SDKs and CLI. Co-authored-by: TRAE CLI <noreply@bytedance.com> * fix(session): align session config interfaces Replace the generic session create config JSON flag with explicit event-tag and auto-commit options. Preserve omitted, object, and null auto-commit semantics across HTTP, embedded clients, SDKs, and CLI, reject ambiguous null policy fields, and handle nullable event configuration consistently. Co-authored-by: TRAE CLI <noreply@bytedance.com> * test(session): trim redundant event tag tests --------- Co-authored-by: TRAE CLI <noreply@bytedance.com> Co-authored-by: qin-ctx <qinhaojie.exe@bytedance.com>
frankyang2008-eng
added a commit
to frankyang2008-eng/OpenViking
that referenced
this pull request
Oct 9, 2026
Sync upstream main (e546b79) - 19 commits, 315 files: - refactor(client): remove Python embedded mode (volcengine#3712) - perf(queue): stream semantic vectorization tasks (volcengine#3636) - perf(queuefs): defer embedding content materialization (volcengine#3871) - feat(memory): support event tag filtering (volcengine#3850) - feat(pathlock): keep lease alive across handoff (volcengine#3903) - feat(server): refresh read-replica API key index via store watcher (volcengine#3857) - feat(agent-evolution): add trajectory date filters (volcengine#3915) - feat(agent-evolution): add trajectory task query (volcengine#3856) - feat(web-studio): add account deletion workflow (volcengine#3912) - feat(web-studio): add scheduled resource sync management (volcengine#3909) - fix(watch): avoid global lock during resource moves (volcengine#3833) - fix(observer): ignore historical lock diagnostics in health (volcengine#3920) - fix(session): validate archive names when loading history (volcengine#3922) - fix(task-tracker): delete expired persisted tasks (volcengine#3913) - fix(storage): exclude zero-byte files from index expectations (volcengine#3904) - fix(semantic): reduce entity hallucinations in summaries (volcengine#3908) - fix(retrieval): record first-turn session recalls (volcengine#3907) - fix(opencode-plugin): serialize saveState to prevent ENOENT race (volcengine#3885) - fix(examples): align quick start with server mode (volcengine#3923) Reviewed: zero conflicts, all local dev-branch modifications preserved, no references to deleted embedded client modules, config backward-compatible.
frankyang2008-eng
pushed a commit
to frankyang2008-eng/OpenViking
that referenced
this pull request
Oct 9, 2026
* feat(memory): support event tag filtering Add session-level default event tags, commit-time overrides, durable queue propagation, and first-write vector index tagging. Include config update APIs and coverage for serialization, concurrency, extraction, and HTTP behavior. Co-authored-by: TRAE CLI <noreply@bytedance.com> * feat(memory): expose event tags in SDKs and CLI Add session default tag configuration, config updates, and commit-time event tag overrides across embedded Python, standalone Python, TypeScript, Go, and the Rust CLI. Preserve explicit empty-tag semantics and document each public interface. Co-authored-by: TRAE CLI <noreply@bytedance.com> * fix(sdk): align legacy session tag APIs Forward commit-time event tags through the legacy Python HTTP shims and align BaseClient session signatures without adding a new abstract-method requirement for existing subclasses. Co-authored-by: TRAE CLI <noreply@bytedance.com> * feat(session): allow updating auto-commit policy Extend PATCH session config to atomically update event tags and auto-commit settings. Merge policy objects by field, use explicit null to disable automatic commits, preserve omitted fields, and expose the contract across SDKs and CLI. Co-authored-by: TRAE CLI <noreply@bytedance.com> * fix(session): align session config interfaces Replace the generic session create config JSON flag with explicit event-tag and auto-commit options. Preserve omitted, object, and null auto-commit semantics across HTTP, embedded clients, SDKs, and CLI, reject ambiguous null policy fields, and handle nullable event configuration consistently. Co-authored-by: TRAE CLI <noreply@bytedance.com> * test(session): trim redundant event tag tests --------- Co-authored-by: TRAE CLI <noreply@bytedance.com> Co-authored-by: qin-ctx <qinhaojie.exe@bytedance.com>
skloxo
pushed a commit
to skloxo/OpenVikingStudio
that referenced
this pull request
Nov 9, 2026
* feat(memory): support event tag filtering Add session-level default event tags, commit-time overrides, durable queue propagation, and first-write vector index tagging. Include config update APIs and coverage for serialization, concurrency, extraction, and HTTP behavior. Co-authored-by: TRAE CLI <noreply@bytedance.com> * feat(memory): expose event tags in SDKs and CLI Add session default tag configuration, config updates, and commit-time event tag overrides across embedded Python, standalone Python, TypeScript, Go, and the Rust CLI. Preserve explicit empty-tag semantics and document each public interface. Co-authored-by: TRAE CLI <noreply@bytedance.com> * fix(sdk): align legacy session tag APIs Forward commit-time event tags through the legacy Python HTTP shims and align BaseClient session signatures without adding a new abstract-method requirement for existing subclasses. Co-authored-by: TRAE CLI <noreply@bytedance.com> * feat(session): allow updating auto-commit policy Extend PATCH session config to atomically update event tags and auto-commit settings. Merge policy objects by field, use explicit null to disable automatic commits, preserve omitted fields, and expose the contract across SDKs and CLI. Co-authored-by: TRAE CLI <noreply@bytedance.com> * fix(session): align session config interfaces Replace the generic session create config JSON flag with explicit event-tag and auto-commit options. Preserve omitted, object, and null auto-commit semantics across HTTP, embedded clients, SDKs, and CLI, reject ambiguous null policy fields, and handle nullable event configuration consistently. Co-authored-by: TRAE CLI <noreply@bytedance.com> * test(session): trim redundant event tag tests --------- Co-authored-by: TRAE CLI <noreply@bytedance.com> Co-authored-by: qin-ctx <qinhaojie.exe@bytedance.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Memory 事件记忆自定义标签(自动打标)设计方案
feat/memory-event-auto-tags(.worktrees/memory-event-auto-tags)0dbc7f397f11446ca75812ba88f168813345936e1. 结论先行:本次增量是「事件记忆自动打标」
对照 PRD 的三块需求,逐条核对功能分支开发前的
main:attrs/set_tags、attrs查看)find/search的tags)已实现部分的代码锚点(无需改动,仅作证据):
POST /api/v1/fs/attrs/set_tags:openviking/server/routers/content.py:90(SetTagsRequest支持uri/tags/mode(replace|append)/recursive/telemetry),存储实现openviking/storage/content_write.py:566+ 目录递归:1105,落到 VikingDBsearch_tags字段(openviking/storage/viking_vector_index_backend.py:998update_search_tags)。GET /api/v1/fs/attrs:openviking/server/routers/filesystem.py:174,resource 返回attrs.tags,memory 额外返回attrs.memory。与 PRD 1.2 的响应结构一致。find/search的tags:openviking/server/routers/search.py(FindRequest.tags:115、SearchRequest.tags:168),过滤语义openviking/utils/tags.py(build_search_tags_filter生成 AND + 精确匹配)。ov attrs set-tags --tags --mode --recursive(crates/ov_cli/src/main.rs:250)、ov find/search --tags(main.rs:717、:787)。2. 关键架构发现(决定注入点)
2.1
events属于「长期记忆」,不是执行类记忆EXECUTION_MEMORY_TYPES = {trajectories, experiences}(openviking/session/memory/constants.py:7)。events由 schemaopenviking/prompts/templates/memory/events.yaml定义,走 长期记忆抽取(extract_long_term_memories),不是执行类记忆的 split 路径。2.2 线上启用的是 V3 compressor,事件走「批处理 StreamingMemoryUpdater」
create_session_compressor返回SessionCompressorV3(openviking/session/__init__.py:40),service/core.py:375使用它。SessionCompressorV3.extract_long_term_memories(compressor_v3.py:304)→_extract_user_memories(:532)→ 不是直接apply_operations,而是StreamingMemoryUpdater.submit(MemoryUpdateRequest(...))(compressor_v3.py:597)。apply_operations(streaming_memory_updater.py:341append-only 快路径、:395分组 flush、最终_apply_operations:435→MemoryUpdater.apply_operations)。2.3 已存在的、可复用的「首次向量化即打标」机制
MemoryUpdater.apply_operations(search_tags_by_uri=...)(memory_updater.py:803)→_vectorize_memories(:1290)→ 在首次 embedding 消息上挂载:(
memory_updater.py:1391-1398)这正是「在原本写入向量库时设置 tags,而不是写完再调一遍 set_tags」的机制 —— 第一次 upsert 就带上
search_tags,无二次写、无异步竞态。事件记忆的目标 URI 在apply_operations之前已经确定(extract_loop.py:405-441绑定resolved_op.uris),所以完全可行。2.4 结论:注入方式
采用 「per-operation 携带 tags + MemoryUpdater 内部聚合成 search_tags_by_uri」:
events类型ResolvedOperation上(复用/新增一个轻量字段)。MemoryUpdater.apply_operations内部,从带 tags 的 op 构建uri→tags映射(若调用点也显式传了search_tags_by_uri,两者合并;trajectory 现有行为不受影响)。_vectorize_memories的挂载逻辑,首次向量化即写入search_tags。这样无论 batch 如何合并,tags 都跟着 op 走,天然正确。
3. 端到端数据流(改造后)
标签优先级(与 PRD 及既往记忆一致):
event.tags=[]→ 本次不注入 session 默认标签(--no-event-tags),不删除同 URI 已有标签event.tags→ 覆盖 session 默认event_search_tags4. 分层改造清单
4.1 存储/会话元数据层
openviking/session/session.py—SessionMeta(class 定义:418)event_search_tags: Optional[List[str]] = None(放在memory_policy/auto_commit_policy旁,:461/:464)。语义:None未设置,[]显式空默认。to_dict(:472)/from_dict(:503)同步序列化,from_dict用data.get("event_search_tags")以兼容旧数据(读旧会话该字段为None,行为不变)。4.2 Session 创建 / 查看 / 配置更新(HTTP)
openviking/server/routers/sessions.pyCreateSessionRequest新增顶层可选字段memory_extraction_config。model_config = {"extra": "forbid"}):MemoryExtractionConfigRequest { events: Optional[EventExtractionConfigRequest] }EventExtractionConfigRequest { tags: Optional[List[str]] = None }None=未指定、[]=显式空、非空=设定;校验和归一化统一由 service 层调用normalize_search_tags。_event_tags_from_extraction_config(...)从memory_extraction_config.events.tags取值,传入service.sessions.create(..., event_tags=...)。result.memory_extraction_config回显有效配置。GET /sessions/{session_id}:result.memory_extraction_config.events.tags。event_search_tags,避免内部字段泄漏。auto_commit_policy继续作为顶层字段返回。PATCH /sessions/{session_id}/config:body 为UpdateSessionConfigRequest { memory_extraction_config, telemetry },复用_event_tags_from_extraction_config;events.tags=[]表示清空默认。变更从下一次 commit 起生效。CommitRequest(:503)新增可选extraction_metadata: Optional[ExtractionMetadataRequest]:ExtractionMetadataRequest { event: Optional[EventExtractionMetadataRequest] }EventExtractionMetadataRequest { tags: Optional[List[str]] = None }(三态:None=用默认,[]=本次不注入默认标签,非空=覆盖默认值;同样不在模型层归一化)。_commit_event_tags(body.extraction_metadata)(sessions.py:_commit_event_tags)取值,仅当结果is not None时写入commit_kwargs["event_tags"](可为[])。最终未采用额外的
config包裹。原因是 GET 返回的整层config容易被客户端直接作为 PATCH body 回写,但其中可能混入不可编辑字段;同时auto_commit_policy已是顶层字段。将memory_extraction_config平铺后,创建、查看和 PATCH 的配置形状一致,PATCH body 可直接从 GET 的同名字段构造。最终 HTTP 示例:
4.3 Service 层
openviking/service/session_service.pycreate(...)(:210)新增event_tags: Optional[List[str]] = None,非None时session.meta.event_search_tags = normalize_search_tags(event_tags)(:255)。effective_memory_extraction_config(session) -> Dict(staticmethod),只产出对外 extraction 配置:{ "events": {"tags": [...]} }memory_extraction_config字段中;无默认时回显events.tags=[]。update_config(session_id, ctx, *, event_tags=None):get出 session,event_tags非None时归一化后调用session.update_event_search_tags(...),返回 session。commit_async(...)(:397)/commit(...)(:363)新增event_tags: Optional[List[str]] = None,非None时放入commit_kwargs["event_tags"],透传给session.commit_async。4.3.1 PATCH 并发与锁设计
PATCH 不能直接使用调用方加载时的整份
SessionMeta覆盖.meta.json,否则可能回滚并发add_message或 commit 更新的message_count、pending_tokens等字段。最终实现将更新收敛到Session.update_event_search_tags():.meta.json。event_search_tags。该方案没有为每次
add_message额外增加一把新锁;消息写入本来就通过 session path lock 保证一致性。PATCH 只在配置变更请求自身增加一次同粒度锁操作。其成本是一次元数据读写和短临界区,不引入额外状态机、缓存或轮询,且避免无锁整对象覆盖造成的数据回退。4.4 Commit → 队列消息
openviking/session/session.pySession.commit_async(:1738)新增event_tags: Optional[List[str]] = None。SessionCommitMsg(:1998)前,用模块级 helper 解析三态(session.py:167_resolve_event_search_tags):SessionCommitMsg(..., event_search_tags=list(effective_event_tags))。openviking/storage/queuefs/session_commit_msg.pyevent_search_tags: List[str] = field(default_factory=list)(有默认值,旧队列 payload 反序列化不受影响;from_dict已忽略未知字段)。openviking/session/session.py— 消费侧resume_queued_commit(消费侧):把msg.event_search_tags透传给_run_memory_extraction(event_search_tags=list(msg.event_search_tags or []))(session.py:2270)。_run_memory_extraction(:2296)新增参数event_search_tags: Optional[List[str]] = None,向下传给长期记忆抽取(:2561的extract_long_term_memories(event_search_tags=...))。4.5 抽取层(V3,真正打标处)
openviking/session/compressor_v3.pyextract_long_term_memories(:324)新增event_search_tags: Optional[List[str]] = None,透传给_extract_user_memories(:372)。_extract_user_memories(:554)在orchestrator.run()得到operations之后、updater.submit()之前,调用模块级 helper_apply_event_search_tags(operations, event_search_tags)(compressor_v3.py:100、调用点:612):只给memory_type == "events"(_EVENTS_MEMORY_TYPE,:91引自constants.EVENT_MEMORY_TYPE)的 upsert op 写op.search_tags。None/[]或operations is None为 no-op。openviking/session/compressor_v2.pyextract_long_term_memories同步新增event_search_tags参数以保持接口一致,但 V2 非线上路径,接受但忽略(del event_search_tags)。openviking/session/memory/constants.pyEVENT_MEMORY_TYPE = "events",供 compressor 与聚合逻辑共用,避免字符串字面量散落。4.6 MemoryUpdater 聚合 + 首次向量化打标
方式:给
ResolvedOperation增加一个显式的 transient search_tags 字段,随 op 穿过 StreamingMemoryUpdater 的 batch 合并。openviking/session/memory/dataclass.py—ResolvedOperation(:294)search_tags: Optional[List[str]] = None(dataclass.py:304,紧邻source之后)。清晰、不污染memory_fields,序列化到队列/patch-merge 时天然可携带。operation_mode="add_only"的 append-only 快路径model_copy(deep=True)(streaming_memory_updater.py)会原样保留该字段。openviking/session/memory/memory_updater.py—apply_operations(:835)_collect_search_tags_by_uri(operations, caller_map=None)(memory_updater.py:74):operations.upsert_operations,对带非空search_tags的 op,把op.uris里每个 uri 映射到list(tags);None/[]的 op 不贡献。caller_map(trajectory 显式 map)优先级更高(冲突时覆盖 per-op)。apply_operations内构建effective_search_tags_by_uri = _collect_search_tags_by_uri(operations, search_tags_by_uri)(:952),传给_vectorize_memories(search_tags_by_uri=...)(:960)。_vectorize_memories(:1424)在首次 upsert 写search_tags。4.7 CLI(低优,Rust)
crates/ov_cli/src/main.rs+commands/session.rs:ov session new增加--event-tags k=v,...(映射memory_extraction_config.events.tags)与--config-json透传。ov session commit增加--event-tags(映射extraction_metadata.event.tags)与--no-event-tags(显式传event.tags=[])。ov session config set <id> --event-tags(映射PATCH /config)。ov session get展示顶层memory_extraction_config。本次提交未实现上述 session CLI 参数。
4.8 Python 内嵌 SDK
本次已为内嵌客户端补齐创建 session 的参数:
AsyncOpenViking.create_session(..., memory_extraction_config=...)SyncOpenViking.create_session(..., memory_extraction_config=...)LocalClient.create_session(...)负责解析并写入默认事件 tags。memory_extraction_config,不暴露event_search_tags。本次未完整扩展独立 HTTP Python SDK、TypeScript SDK、Go SDK,也未为所有 SDK 增加 PATCH 配置和 commit tag override 的强类型封装;调用者仍可直接使用 HTTP API。这属于后续 SDK parity 工作,不影响服务端能力。
5. 与已有 WIP(
.worktrees/memory-event-tags)的差异旧 WIP 已完成了请求模型、
SessionMeta.event_search_tags、SessionCommitMsg.event_search_tags、PATCH /config等骨架,可参考借鉴。但其抽取侧注入方式是错误/未完成的:self._apply_event_search_tags(event_memory_uris, ...)(session.py:2642),但该方法没有实现(grep 无def _apply_event_search_tags),代码是坏的。本方案改为「首次向量化随记录写入」,从抽取阶段给 op 带 tags,彻底避免二次写。旧 WIP worktree 保持不动。
6. 兼容性与边界
SessionMeta/SessionCommitMsg新字段均有默认值,旧会话与旧队列消息反序列化行为不变(新字段为None/[])。normalize_search_tags(小写、去重、k=v校验),与attrs/set_tags、find/search完全一致,检索侧无需特殊处理。event.tags=[]与--no-event-tags对应,明确「本次不注入默认标签」;不会删除同 URI 已存在的文件标签。search_tags,聚合 map 里不出现,行为零变化。commit_async,会自动带上 session 默认event_search_tags,无需额外改动。7. 测试与验证结果
7.1 自动化测试
已落地 30 个定向自动化用例:
tests/unit/session/test_event_search_tags.py(4):SessionMeta.to_dict/from_dictround-trip,含/不含字段、旧 dict 缺字段为None。tests/storage/test_session_commit_msg_event_tags.py(3):SessionCommitMsground-trip,旧 payload(无字段)反序列化为[]。tests/unit/session/test_event_op_search_tags.py(5):ResolvedOperation.search_tags字段 +_collect_search_tags_by_uri聚合(per-op、caller_map 优先、None/[]不贡献)。tests/unit/session/test_event_tags_resolution.py(5):_resolve_event_search_tags三态(session 默认 / commit 覆盖 /[]禁用默认标签注入 / 都无 / 归一化)。tests/unit/session/test_compressor_v3_event_tags.py(4):_apply_event_search_tags只给eventsop 打标;非 events、None/[]、operations is None均 no-op。tests/unit/session/test_event_tag_concurrency.py(3):PATCH 与消息/commit 元数据并发更新时不回滚其它字段。tests/server/test_api_sessions_event_tags.py(6):顶层memory_extraction_config的 create/get/PATCH 契约、内部字段隐藏、commit override。最近一次定向执行结果:30 个 event-tag HTTP/unit tests 全部通过;另有 7 个 create/get/commit 兼容性测试通过,Ruff 与
git diff --check通过。7.2 本地全链路 E2E
脚本:
.local/e2e_memory_event_tags.sh(仅本地,不提交 Git)。运行环境:
~/.openviking/ov.conf的模型配置。最近一次日志:
.local/e2e-logs/event-tags-e2e-20260806194104-62284.log结果:
116 PASS / 0 FAIL,脚本退出码0,队列未出现error_count > 0。覆盖 7 组场景:tags=[]禁用本次默认注入。find/search、GET attrs、set_tags append/replace、同 key 更新。7.3 非本功能失败
宽范围
tests/server/test_http_client_sdk.py曾执行为 15 passed、9 failed。失败集中在资源/VLM 依赖和既有跨 event-loop task tracker fixture,不是 event-tag 定向用例;本次没有扩大范围修复这些无关问题。8. 交付顺序(已按此完成)
SessionMeta.event_search_tags+ 序列化)+ 单测。SessionCommitMsg.event_search_tags+ 单测。commit_async三态解析 +resume_queued_commit/_run_memory_extraction透传 + 单测。ResolvedOperation.search_tags+MemoryUpdater._collect_search_tags_by_uri聚合 + 单测。_apply_event_search_tags+EVENT_MEMORY_TYPE)+ 单测;compressor_v2 接口对齐(接受但忽略)。create/update_config/commit_async+effective_memory_extraction_config。PATCH /config/commitextraction_metadata)+ HTTP 规格用例。9. 设计稿到最终实现的关键修正
规划稿与最终落地的主要差异,供 review 对照:
_collect_search_tags_by_uri(operations, caller_map)(memory_updater.py:74),可单测、且明确 caller_map 覆盖 per-op。_resolve_event_search_tags(commit_tags, session_default_tags)(session.py:167)。_apply_event_search_tags(operations, event_search_tags)(compressor_v3.py:100),并新增constants.EVENT_MEMORY_TYPE = "events"避免字面量散落。EventExtractionConfigRequest.tags使用Optional[List[str]] = None,把归一化收敛到 service 层——否则模型层None→[]会吃掉「未指定」与「清空」的三态区分。config包裹:最终 create/get/PATCH 都使用顶层memory_extraction_config;避免 GET 的混合配置对象被直接回写给只允许更新 extraction 配置的 PATCH。auto_commit_policy保持顶层且 PATCH 不编辑它。effective_memory_extraction_config,只构造{"events":{"tags":[...]}};路由负责放入顶层字段。extract_long_term_memories同样增加event_search_tags参数(del忽略),保证两个 compressor 接口一致,避免调用点分叉。ResolvedOperation使用显式字段:落地search_tags: Optional[List[str]] = None(dataclass.py:304),不污染memory_fields,append-onlymodel_copy(deep=True)天然保留。SessionMeta整体覆盖,防止并发消息写入和 commit 更新被回滚;未给 add-message 路径增加额外锁。memory_extraction_config,但其它语言和 commit/PATCH SDK 封装留作后续。10. 最终行为与边界总结
key=value字符串列表;统一小写、按 key 归一化并校验。tags=[]只是不为本次新产出的事件注入默认 tags,不删除复用 URI 上已有 tags。ResolvedOperation穿过 StreamingMemoryUpdater 的 batch 合并,并在原始向量 upsert 中写入,不进行事后二次set_tags。search_tag_mode="append"保留文件已有的其它 key;相同 key 使用新值。auto_commit_policy当前仍是创建时配置,不在该 PATCH 中修改。